#!/bin/bash

read -p "服务名：" server
port=$(netstat -tunlp | grep $server | awk '{print $4}'| awk -F: '{print $NF}'| uniq |tr '\n' ' ')
pid=$(netstat -tunlp | grep $server | awk '{print $NF}'|uniq|awk -F/ '{print $1}')
time=$(systemctl show -p ActiveEnterTimestamp $server | awk '{print $2,$3}')
if netstat -tunlp | grep $server &> /dev/null;then
    echo "port:$port"
    echo "pid:$pid"
    echo "time:$time"
else
    echo '服务不存在'

fi
